# Contributor: Philipp Andronov <filipp.andronov@gmail.com>
# Maintainer: Matt Smith <mcs@darkregion.net>
pkgname=libexecinfo
pkgver=1.1
pkgrel=1
pkgdesc="A quick-n-dirty BSD licensed clone of the GNU libc backtrace facility."
options="!check" # No testsuite
url="https://www.freshports.org/devel/libexecinfo"
arch="all"
license="BSD-2-Clause"
subpackages="$pkgname-static ${pkgname}-dev"
source="http://distcache.freebsd.org/local-distfiles/itetcu/$pkgname-$pkgver.tar.bz2
	10-execinfo.patch
	20-define-gnu-source.patch
	30-linux-makefile.patch
	"

build() {
	cd "$builddir"
	export CFLAGS="${CFLAGS} -fno-omit-frame-pointer"
	make
}

package() {
	cd "$builddir"

	install -D -m755 "$builddir"/execinfo.h \
		"$pkgdir"/usr/include/execinfo.h
	install -D -m755 "$builddir"/stacktraverse.h \
		"$pkgdir"/usr/include/stacktraverse.h
	install -D -m755 "$builddir"/libexecinfo.a \
		"$pkgdir"/usr/lib/libexecinfo.a
	install -D -m755 "$builddir"/libexecinfo.so.1 \
		"$pkgdir"/usr/lib/libexecinfo.so.1
	ln -s /usr/lib/libexecinfo.so.1 \
		"$pkgdir"/usr/lib/libexecinfo.so
}

static() {
	depends=""
	pkgdesc="$pkgdesc (static library)"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib
}

sha512sums="51fea7910ef6873061a25c22434ce4da724e9d8e37616a069ad0a58c0463755be4c6c7da88cd747484c2f3373909d7be4678b32a4bd91b6d9e0f74526094e92c  libexecinfo-1.1.tar.bz2
cd35c9046d88b39b05bc36faffb1e71ae3b2140632da7da37f374fff671d4ad812eebd0581011ff9e3b25d3cb4bc962cf35957074f713817b3b617511425af1a  10-execinfo.patch
c961b2f86cba291e8c69a507e3880354ad7369fd04c8948d54c4db0578fe30cca8f4250742cb63d1ab6e5875988f04c4729256197030369404f0e925f299a66c  20-define-gnu-source.patch
13d3df88a6dabd78ee2cf50092511f5a10f0e5ff3d81dbacb182fcf85ceb0c13a5f0252397b4eb0ac57f8d8bd3fc3af6c05865d6398cbc1517f347210c5750da  30-linux-makefile.patch"
